#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    int m , n ;
    cin >> m >> n;
    vector<string> matrix(m);
    vector<int> check(26);
    check['l'-'a'] = 4 , check['o'-'a'] = 3 , check['v' - 'a'] = 2 , check['e'-'a'] = 1;
    for(int i = 0 ; i < m ; ++i) cin >> matrix[i];
    vector<vector<int>> dp(m+1,vector<int>(n+1));
    int ret = 0;
    for(int i = 1 ; i <= m ; ++i)
    {
        for(int j = 1 ; j <= n ; ++j)
        {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]) + check[matrix[i-1][j-1]-'a'];
            ret = max(ret,dp[i][j]);
        }
    }
    cout << ret << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")